{% extends 'inventory/base.html' %}

{% block title %}会员等级管理 - {{ block.super }}{% endblock %}

{% block content %}
<div class="row mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-3">
                    <div>
                        <h2 class="card-title mb-0">会员等级管理</h2>
                        <p class="text-muted mb-md-0">管理会员等级、折扣及升级条件</p>
                    </div>
                    <div class="d-flex flex-wrap gap-2">
                        <a href="{% url 'member_list' %}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left me-1"></i> 返回会员管理
                        </a>
                        <a href="{% url 'member_level_create' %}" class="btn btn-primary">
                            <i class="bi bi-plus-circle me-1"></i> 添加会员等级
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row mb-4">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="table-responsive">
                    <table class="table table-striped table-hover align-middle">
                        <thead class="table-light">
                            <tr>
                                <th>等级名称</th>
                                <th>折扣率</th>
                                <th>升级所需积分</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for level in levels %}
                            <tr>
                                <td>
                                    <span class="fs-5 d-flex align-items-center">
                                        <i class="bi bi-award text-primary me-2"></i>
                                        {{ level.name }}
                                    </span>
                                </td>
                                <td>
                                    <span class="badge bg-success">{{ level.discount|floatformat:2 }}</span>
                                </td>
                                <td>
                                    <span class="fw-bold">{{ level.points_threshold }} 分</span>
                                </td>
                                <td>
                                    <small>{{ level.created_at|date:"Y-m-d" }}</small>
                                </td>
                                <td>
                                    <div class="btn-group">
                                        <a href="{% url 'member_level_edit' level.id %}" class="btn btn-sm btn-outline-primary" title="编辑">
                                            <i class="bi bi-pencil"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            {% empty %}
                            <tr>
                                <td colspan="5" class="text-center py-5">
                                    <div class="d-flex flex-column align-items-center">
                                        <i class="bi bi-award text-muted" style="font-size: 2.5rem;"></i>
                                        <p class="mt-3 mb-1">暂无会员等级数据</p>
                                        <small class="text-muted">点击"添加会员等级"按钮创建会员等级</small>
                                    </div>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 